package com.trailwalker.javafx.utils.stage;

import javafx.scene.image.Image;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * @author Trailwalker
 * @create 2021-08-31 14:24
 * @des
 */
public class StageUtils {

    private static final String TAG = StageUtils.class.getSimpleName();

    /**
     * 显示窗口
     *
     * @param stage
     */
    public static void show(Stage stage) {
        stage.show();
    }

    /**
     * 设置窗口标题
     *
     * @param stage
     * @param title
     */
    public static void setTitle(Stage stage, String title) {
        stage.setTitle(title);
    }

    /**
     * 添加图标
     *
     * @param stage
     * @param image
     */
    public static void addIcon(Stage stage, Image image) {
        stage.getIcons().add(image);
    }

    /**
     * set window minimization
     *
     * @param stage
     */
    public static void setIconified(Stage stage) {
        stage.setIconified(true);
    }

    /**
     * set window maximization
     *
     * @param stage
     */
    public static void setMaximized(Stage stage) {
        stage.setMaximized(true);
    }

    /**
     * 关闭窗口
     *
     * @param stage
     */
    public static void close(Stage stage) {
        stage.close();
    }

    /**
     * 设置窗口大小是否可变
     *
     * @param stage
     */
    public static void setResizable(Stage stage, boolean value) {
        stage.setResizable(value);
    }

    /**
     * 设置窗口全屏
     * need set scene on stage and full-screen mode takes effect
     *
     * @param stage
     */
    public static void setFullScreen(Stage stage, boolean value) {
        stage.setFullScreen(value);
    }

    /**
     * 设置窗口透明度
     *
     * @param stage
     */
    public static void setOpacity(Stage stage, double value) {
        stage.setOpacity(value);
    }

    /**
     * 设置窗口置顶
     *
     * @param stage
     */
    public static void setAlwaysOnTop(Stage stage, boolean value) {
        stage.setAlwaysOnTop(value);
    }

    /**
     * 设置窗口样式
     *
     * @param stage
     * @param stageStyle
     */
    public static void initStyle(Stage stage, StageStyle stageStyle) {
        stage.initStyle(stageStyle);
    }

}
